Repository navigation
fix(ingest/bigquery): rebuild dataset_pattern instead of mutating it; qualify alternations - #21430
sgomezvillamor wants to merge 10 commits into
Conversation
…ld patterns instead of mutating them - AllowDenyPattern._rebuilt(**overrides): derive a pattern without carrying the compiled-regex cache; used by with_deny and the probe's trial pattern. - BigQuery: dataset_pattern is rebuilt, not edited in place, so a pattern that was already used no longer keeps matching its old entries. Entries are qualified per alternation branch, and only a separator dot (`\.` or `.` before a name character) marks an entry as project-qualified, so `^staging_.*` and `a|b` work. schema_pattern is no longer aliased. - Snowflake: deny `^(.*\.)?INFORMATION_SCHEMA$` instead of `.*INFORMATION_SCHEMA$`, so MY_INFORMATION_SCHEMA is no longer dropped; container_blind recognises the new shape. - Use is_allow_all() instead of comparing against allow_all(), except in the Dataplex validator, where it would reject recipes accepted today.
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Smart test selectionpytest smoke testsMode: active. Only the selection below runs for the pytest smoke tests on this PR (applied:
Selected scopes (145 files or classes, 715 tests)
Add the commit |
An entry whose only dots may be either the project separator or a regex wildcard (`my-project.*`, `^staging_.*`) now gets an optional "any project" prefix, `(?:.*\.)?`, so it keeps every match it had on master and also matches as a dataset-name regex. Entries with no dot keep the `.*\.` prefix. Leading inline flags stay in front of the prefix, and an entry that still cannot be qualified logs a warning.
|
🤖 Opened with cclaude on behalf of @sgomezvillamor |
Connector Tests ResultsAll connector tests passed for commit To skip connector tests, add the Autogenerated by the connector-tests CI pipeline. |
… a simple wrap Keep master's rule for which entries get the project prefix (no `.` means a dataset name; any `.` means matched as written), but wrap the qualified entry in a group, `.*\.(?:<entry>)`, so every alternative of `a|b` is qualified. The rebuild instead of in-place edits, the separate schema_pattern object and the rest of the fix are unchanged.
…t-pattern-rebuild # Conflicts: # docs/how/breaking-changes.md
PR SummaryOverview BigQuery Snowflake: Default deny for metadata schemas changes from Across connectors: Comparisons to the default allow-all pattern use Reviewed by Cursor Bugbot for commit ff6d1ba. Bugbot is set up for automated code reviews on this repo. Configure here. |
…t-pattern-rebuild # Conflicts: # docs/how/breaking-changes.md
…ntain | Entries without alternation keep master's qualified spelling (.*\.foo), so anything comparing or displaying the qualified pattern is unchanged. Also narrow _rebuilt's override types and document the mixed-alternation case in the breaking-changes entry.
It is called from other modules and documented as the way to derive a pattern, so give it a public name alongside with_deny.
Follow-up to #21184.
AllowDenyPatterncaches its compiled regexes on first use, so a pattern whoseallow/denylists are edited in place, or that is copied withmodel_copy/deepcopy, keeps matching the old entries. BigQuery editeddataset_patternin place, and that rewrite also qualified only the first alternative of an entry likea|b.Changes
AllowDenyPattern.with_fields(**overrides)(configuration/common.py)Builds a new pattern from
model_dump()plus overrides, so it starts with no regex cache. The docstring explains why notmodel_copy: it copies__dict__, cache included.with_denyand the probe's_trial_patternnow use it.BigQuery
dataset_pattern(bigquery_config.py,backward_compatibility_configs_set)deepcopyor the probe's revalidation) was rewritten to.*\.mydatasetbut still matchedmydataset, soproj.mydatasetwas rejected.schema_patternis no longer shared withdataset_patternwhen it is used as the fallback;dataset_patterngets its own copy.allowanddeny. Which entries get the project prefix is decided exactly as on master: an entry with no.names a dataset; an entry with any.is matched as written. What changes is how the prefix is added to an entry with a|: it is wrapped in a group,.*\.(?:<entry>)(or^.*\.(?:<rest>)for a leading^), soa|bbecomes.*\.(?:a|b). Before, only the first alternative was qualified. Entries without a|keep master's spelling (^foo$→^.*\.foo$).Known limitations (unchanged from master, pinned with strict
xfailtests):., such as^staging_.*, is still taken as project-qualified and matched as written against<project_id>.<dataset_name>, so it matches nothing. The note inbreaking-changes.mdtells users to write.*\.staging_.*.^is moved in front of the prefix, so^a|^bbecomes^.*\.(?:a|^b), and its second alternative can't match.., such asa|proj\.b, is kept as written, soais still matched against project IDs;breaking-changes.mdnotes this.Snowflake
INFORMATION_SCHEMAdeny^(.*\.)?INFORMATION_SCHEMA$instead of.*INFORMATION_SCHEMA$. It still deniesINFORMATION_SCHEMAandDB.INFORMATION_SCHEMA, and no longer drops schemas likeDB.MY_INFORMATION_SCHEMA. Python'sre.matchis anchored at the start, so(^|\.)INFORMATION_SCHEMA$would have stopped denying the qualified name.SNOWFLAKE_INFORMATION_SCHEMA_DENY.agent/verdicts.container_blindrecognises the^(.*\.)?<literal>$shape. Without that,probe filterrefuses every Snowflake schema verdict for lack of a container.is_allow_all()All
!= / == AllowDenyPattern.allow_all()comparisons now useis_allow_all(): superset, path_spec, BigQuery, Redshift, Power BI and Snowflake. The two checks differ only for patterns that allow everything but aren't the default (ignoreCase: false,allow: [".*", "x"]), whichis_allow_all()gets right. Superset compared after the pattern had been used, so the comparison was always true, which caused an extra dataset lookup per chart.A few branches change for such patterns:
dataset_patternofallow: [".*", "foo"]together with aschema_patternnow falls back to theschema_pattern.workspace_id_patternofallow: [".*"], ignoreCase: falsetogether with aworkspace_idnow narrows to that one workspace.tables_filter_patterntogether withemit_folders_onlyis now accepted instead of rejected.The Dataplex validator is the one exception, with a comment explaining why: switching it would start rejecting recipes whose only project selector is such a pattern.
Tests
tests/unit/bigquery/test_bigquery_dataset_pattern.py, which goes throughBigQueryFilter(what the source uses). It covers:.kept as written (includingmy-project.*)validate_pattern_at_process_project_datasetsxfailswith_fieldstests, Snowflake lookalike-schema tests, andcontainer_blindshape tests.config,configuration,bigquery,snowflake,agent, superset,dataplex,redshift,powerbi,data_lake,data_lake_commonands3. Same 52 failures before and after the change, all from optional drivers missing locally (oracledb, clickhouse, teradata, jpype, …); nothing new.ruff check,ruff formatandmypyare clean on the changed files.Breaking changes
I added entries to
docs/how/breaking-changes.mdfor the BigQuery alternation fix (including the dotted-entry limitation) and for the Snowflake rule.